function HotelogixWeb()
{

    /**
     * EX:  var options = {
     *           domain:'http://www.hotelogix.com',
     *          
     *           container:HTML Element object in which Web Engine will draw,     
     *           
     *           hotelId:'Hotel Id',
     *           languageId:'language Id', Default 1(English)
     *           autoHeight:true/false, Default true
     *           id: 'HTML Element object ID in which Web Engine will draw' Default webresframe
     *           height:'Default iframe height' Default 600
     *           width:'Default iframe width' Default "100%"
     *           border:'Default iframe border' Default "0"
     *           scrolling:'Default iframe scrolling' Default "auto"
     *           iframe:'Already implemented iframe element' use for autoHeight function
     *       };
     * @type object
     */
    this.options = {};

    this.options.domain = "https://www.staygrid.com";
    this.options.languageId = 1;

    this.options.id = "webresframe";
    this.options.height = "600";
    this.options.width = "100%";
    this.options.border = "0";
    this.options.scrolling = "auto";
    this.options.autoHeight = true;
    this.options.extraHeight = 90;


    this.ifrm;
    var setToFrameOnload = false;

    this.frameHeight = null;
    
    this.getLastFrameHeight = function()
    {
        return parseFloat(this.frameHeight);
    }

    this.run = function(callBack)
    {
        window.onload = callBack;
    }
    /**
     * Public function to Draw Hotelogix Web Reservation Engine
     * @param {object} options
     * @returns {unresolved}
     */
    this.draw = function(options)
    {

        if (!options)
        {
            exception("Invalid Options", "Invalid Options for web engine");
        }
        if (!options.hotelId || options.hotelId === '')
        {
            exception("Invalid path", "Invalid booking engine hotel");
        }
        if (!options.container || this.container === '')
        {
            exception("Invalid Container", "Valid Container to draw web engine fot found.");
        }

        this.options.container = options.container;
        this.options.hotelId = options.hotelId;




        if (options.domain && options.domain !== '')
        {
            this.options.domain = options.domain;
        }
        if (options.languageId && options.languageId > 0)
        {
            this.options.languageId = options.languageId;
        }


        this.options.url = this.options.domain + "/webreservation/index/index/hidHotelIdWebOut/" + this.options.hotelId + "/hidLanguageId/" + this.options.languageId;


        if (options.id)
        {
            this.options.id = options.id;
        }
        if (options.height)
        {
            this.options.height = options.height;
        }
        if (options.extraHeight)
        {
            this.options.extraHeight = options.extraHeight;
        }
        if (options.width)
        {
            this.options.width = options.width;
        }
        if (options.border)
        {
            this.options.border = options.border;
        }
        if (options.scrolling)
        {
            this.options.scrolling = options.scrolling;
        }
        if (options.autoHeight !== undefined)
        {
            this.options.autoHeight = options.autoHeight;
        }

        if (typeof options.callBack === 'function')
        {
            this.options.callBack = options.callBack;
        }

        prepareFrame.call(this);

        return;

    }

    /**
     * create and add iframe element to given container
     * @returns {undefined}
     */
    var prepareFrame = function()
    {
        var ifrm = document.createElement("IFRAME");

        ifrm.setAttribute("src", this.options.url);
        ifrm.style.width = this.options.width;
        ifrm.style.height = this.options.height;
        ifrm.frameBorder = this.options.border;
        ifrm.scrolling = this.options.scrolling;
        ifrm.id = this.options.id;
        this.ifrm = ifrm;

        this.options.container.appendChild(ifrm);

        this.options.iframe = this.ifrm;
        if (this.options.autoHeight)
        {
            setToFrameOnload = true;

            this.autoHeight(this.options);
        }

    }

    /**
     * Request for current contain height to iframe source(server)
     * @param {object} thisClass
     * @returns {undefined}
     */
    function requestForAutoHeight(thisClass)
    {
        //var o = document.getElementById("webresframe"); 
        //o.contentWindow.postMessage('hlsizing?', thisClass.options.domain);
        if (thisClass.options.iframe.contentWindow.postMessage)
        {
            thisClass.options.iframe.contentWindow.postMessage('hlsizing?', thisClass.options.domain);
        } else
        {
            exception("Invalid Browser", "Browser not support height adjustment.");
        }


    }

    /**
     * attached listener to window for messaging with server
     * @param {event} e
     * @returns {undefined}
     */
    var messageListener = function(e)
    {
        var domain = this.options.domain;
        var ifrm = this.ifrm;
        var extraHeight = parseFloat(this.options.extraHeight);
        var callBackFunc = false;
        if (this.options.callBack)
        {
            callBackFunc = this.options.callBack;
        }

        var handleSizingResponse = function(e)
        {
            //alert("LOCAL:" + e.origin);
            //alert("LOCAL:" + e.data);
            //alert("extraHeight:" + extraHeight);
            if (e.origin === domain)
            {
                var action = e.data.split(':')[0]
                var ht = parseFloat(e.data.split(':')[1]);
                if (action === 'hlremoteHeight')
                {
                    
                    ifrm.style.height = ht + extraHeight + "px";
                    this.frameHeight = ht + extraHeight;
                    //alert("remote send currentHeight: " + ht);
                    //alert(this.frameHeight);
                    if(callBackFunc)
                    {
                        callBackFunc(this);
                    }
                }
                ;
            }
        }

        if (window.addEventListener) {
            window.addEventListener('message', handleSizingResponse, false);
        } else if (window.attachEvent) {
            window.attachEvent('onmessage', handleSizingResponse);
        }
    }


    /**
     * Public function to auto height adjustment of a given Hotelogix Web Reservation Engine
     * @param {type} options
     * @returns {unresolved}
     */
    this.autoHeight = function(options)
    {
        var ifrm = document.getElementById("webresframe");

        if (options)
        {
            if (options.domain && options.domain !== '')
            {
                this.options.domain = options.domain;
            }
            if (options.extraHeight)
            {
                this.options.extraHeight = options.extraHeight;
            }
            if (options.iframe)
            {
                ifrm = options.iframe;
            }
        }

        if (!ifrm)
        {
            exception("Invalid Iframe", "Valid iframe to change height fot found.")
        }
        this.options.iframe = this.ifrm = ifrm;
        var thisClass = this;

        messageListener.call(this);

        if (setToFrameOnload) //Iframe created by this class
        {
            if (ifrm.addEventListener)
            {
                ifrm.addEventListener('load', function() {
                    requestForAutoHeight(thisClass);
                }, true);
            }
            else if (ifrm.attachEvent)
            {
                ifrm.attachEvent('onload', function() {
                    requestForAutoHeight(thisClass);
                }, true);
            }

            /*ifrm.onload = function()
             {
             requestForAutoHeight(onloadPassClass);
             }
             else
             {
             alert(12);
             //requestForAutoHeight(onloadPassClass);
             }*/
        } else //Iframe already created just adjust height by this class
        {
            requestForAutoHeight(thisClass);
        }

        return;
    }



    /**
     * Private exception handle
     * @param {string} name
     * @param {string} message
     * @returns {undefined}
     */
    function exception(name, message)
    {
        throw {
            name: name,
            message: message,
            toString: function() {
                return this.name + ": " + this.message
            }
        }
    }

    /**
     * Get Internet Explorer version
     * @returns {Number}
     */
    function ieVersion()
    {
        var ieversion = 0;
        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) //test for MSIE x.x;
        {
            ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number           
        }
        return  ieversion;
    }
}

